<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>ES11 私有属性</title>
</head>
<body>
  <script>
    class Person {
      //公有属性
      name
      //私有属性
      #age
      #weight

      //构造方法
      constructor (name, age, weight) {
        this.name = name
        this.#age = age
        this.#weight = weight
      }

      intro () {
        console.log(this.name)
        console.log(this.#age)
        console.log(this.#weight)
      }
    }

    //实例化
    const girl = new Person('晓红', 18, '45kg')
    // console.log(girl.name)
    // console.log(girl.#age)  // 私有属性类外部无法访问
    // console.log(girl.#weight)   // 私有属性类外部无法访问

    girl.intro()
  </script>
</body>
</html>